#include "./conn_task.h"
#include "../rtos/thread.h"
#include "../pub_driver/cmd_can.h"

#ifdef APP_MAIN
#include "../main_driver/cmd_uart.h"

using namespace main_driver;
#endif

namespace conn_task {

using namespace conn;
using namespace pub_driver;


template <uint8_t SRC>
struct ConnTask : public rtos::Thread<ConnTask<SRC>, 1024, osPriorityHigh1> {

    void run() {

    }

private:
    void can_recv_from_ipc(const Frame &frame) {
        if (frame.dst() != addr::SELF) {
#ifdef APP_MAIN
            cmdUart->write(frame.buf, frame.len);
#endif
            return;
        }
        dispatch_self(frame);
    }

#ifdef APP_MAIN
    void uart_recv_from_ipc(const Frame &frame) {
        if (frame.dst() != addr::SELF) {
            cmdCAN->write(frame.buf, frame.len);
            return;            
        }

    }
#endif

    void dispatch_self(const Frame &frame) {

    }
};

static ConnTask<addr::IPC> ipcConnTask;

}
